<template id="user" >
  <div style="width: 100%">
    <el-form :inline="true" class="demo-form-inline" style="width: 100%">
      <el-form-item>
        <el-input v-model="keyWord" placeholder="想要搜索的内容"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="localData()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      ref="multipleTable"
      :data="orderList.list"
      tooltip-effect="dark"
      style="width: 100%"
      align="center"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        type="selection"
        width="55"
        prop="order_id"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="users.user_name"
        label="租客姓名"
        width="100"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="stall.stall_code"
        label="车位编号"
        width="100"
        sortable
        align="center"
      ></el-table-column>
      <el-table-column
        prop="vehicle.vehicle_code"
        label="车牌号"
        width="100"
        sortable
        align="center"
      ></el-table-column>
      <el-table-column
        prop="order_startime"
        label="订单开始时间"
        width="150"
        sortable
        align="center"
      ></el-table-column>
      <el-table-column
        prop="order_endtime"
        label="订单结束时间"
        width="150"
        sortable
        align="center"
      ></el-table-column>
      <el-table-column
        prop="order_money"
        label="订单交易金额"
        width="150"
        sortable
        align="center"
      ></el-table-column>
      <el-table-column
        prop="order_state"
        label="订单状态"
        width="100"
        sortable
        align="center"
      ></el-table-column>
    </el-table>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="orderList.pageNum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="5"
      layout="total, sizes, prev, pager, next, jumper"
      :total="orderList.total"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      orderList: {},
      currentPage: 1,
      pageSize: 5,
      ids: [],
      keyWord: "",
      };
  },

  methods: {
    localData() {
      this.$axios
        .get("/selAllOrder", {
          params: {
            keyWord: this.keyWord,
            currentPage: this.currentPage,
            pageSize: this.pageSize,
          },
        })
        .then((res) => {
          this.orderList = res.data.data;
        })
        .catch((error) => {});
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.localData();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.localData();
    },
    handleSelectionChange(val) {
      var ids = []; //存放选中的id
      for (let item of val) {
        ids.push(item.order_id);
      }
      //将选中的所有项的id放到数据模型中
      this.ids = ids;

      console.log(ids);
      //this.multipleSelection = val;
    },
  },

  mounted() {
    // roleId=sessionStorage.getItem('roleId');
    this.localData();
  },
};
</script>